#include "library.h"

Library::Library() {
    std::cout << "Library created." << std::endl;
}

Library::~Library() {
    std::cout << "Library destroyed." << std::endl;
}


void library::addBook(const Book& book) {
    books.push_back(book);
}

void library::deleteBook(const std::string& title) {
    for (int i = 0; i < books.size(); i++) {
        if (books[i].title == title) {
            books.erase(books.begin() + i);
            break;
        }
    }
}

void library::searchBook(const std::string& keyword) {
    for (int i = 0; i < books.size(); i++) {
        if (books[i].title.find(keyword) != std::string::npos) {
            std::cout << books[i].title << std::endl;
        }
    }
}

void library::showAllBooks() const {
    for (int i = 0; i < books.size(); i++) {
        std::cout << books[i].title << std::endl;
    }
}